package jsyf.oa.web.capital;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.capital.BankCardFacade;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * Created by houtailei on 2018/2/25.
 */
@Api(value = "T_CPT_BANK_CARD接口", description = "T_CPT_BANK_CARD接口")
@Controller
@RequestMapping("/bankCard")
public class BankCardController {
    @Resource
    private BankCardFacade bankCardFacade;

    @ApiOperation(value = "添加银行卡", notes = "")
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'人员id'}", dataType = "String", paramType = "body")
    @RequestMapping(value = "/addBankCard.json", method = RequestMethod.POST)
    public void addBankCard(HttpServletResponse response, @RequestBody String jsonData) {
        String id = bankCardFacade.save(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(id.toString()));
    }

    @ApiOperation(value = "获取银行卡信息", notes = "")
    @ApiImplicitParam(name = "jsonData", value = "{'id':'银行卡id'}", dataType = "String", paramType = "body")
    @RequestMapping(value = "/getBankCard.json", method = RequestMethod.POST)
    public void getBankCard(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject id = bankCardFacade.getBankCard(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(id));
    }

    @ApiOperation(value = "修改银行卡", notes = "")
    @ApiImplicitParam(name = "jsonData", value = "{'id':'银行卡id'}", dataType = "String", paramType = "body")
    @RequestMapping(value = "/updateBankCard.json", method = RequestMethod.POST)
    public void updateBankCard(HttpServletResponse response, @RequestBody String jsonData) {
        String id = bankCardFacade.updateBankCard(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(id.toString()));
    }


    @ApiOperation(value = "查看银行卡列表", notes = "")
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'人员id'}", dataType = "String", paramType = "body")
    @RequestMapping(value = "/getBankCardList.json", method = RequestMethod.POST)
    public void getBankCardList(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = bankCardFacade.getBankCardList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }
}
